package com.changpay.zywy.ui.activity.loan

import android.content.Intent
import android.view.View
import com.changpay.zywy.R
import com.changpay.zywy.app.App
import com.changpay.zywy.base.BaseActivity
import com.changpay.zywy.base.IView
import com.changpay.zywy.ext.showToast
import kotlinx.android.synthetic.main.activity_loan_pay_success.*
import kotlinx.android.synthetic.main.title_layout.*

class LoanPaySuccessActivity : BaseActivity(), IView {
    override fun showLoading() {

    }

    override fun hideLoading() {

    }

    override fun showDefaultMsg(msg: String) {
        showToast(msg)
    }

    override fun showMsg(msg: String) {
        showToast(msg)
    }

    override fun showError(errorMsg: String) {
        showToast(errorMsg)
    }


    private val onClickListener = View.OnClickListener { view ->
        when (view.id) {
            R.id.iv_back -> {
                val app = App.instance as App
                app.finishTopActivity(3)
            }
            R.id.btn_zhangdan -> submit()
        }
    }

    private fun submit() {
        Intent(this, LoanHistoryActivity::class.java).putExtra(
            "allot_id",
            intent.getStringExtra("allot_id")
        ).run {
            startActivity(this)
        }
    }

    override fun attachLayoutRes(): Int {
        return R.layout.activity_loan_pay_success
    }

    override fun initData() {

    }

    override fun initView() {

        tv_title.text = "货款管理"
        tv_success_title.text = "本期" + intent.getStringExtra("type") + "成功"
        tv_message.text = intent.getStringExtra("message")
        iv_back.setOnClickListener(onClickListener)
        btn_zhangdan.setOnClickListener(onClickListener)
    }

    override fun onBackPressed() {

        super.onBackPressed()
        val app = App.instance as App
        app.finishTopActivity(3)
    }

    override fun start() {

    }
}
